
#include"List.h"

void Test01(void)
{
    //先申请一个空头节点，然后给其初始化为双向链表
    LTNode* plist = NULL;
    //LTInit(&plist);
    //优化初始化接口
    plist = LTInit2();
    //尾插
    LTPushBack(plist, 3);
    LTPushBack(plist, 4);
    LTPushBack(plist, 5);
    LTPushBack(plist, 6);
    //头插
    LTPushFront(plist, 2);
    LTPushFront(plist, 1);
    LTPrint(plist);
    LTPopBack(plist);//尾删
    LTPrint(plist);
    LTPopFront(plist);//头删
    LTPrint(plist);
    //查找
    LTNode* ret = LTFind(plist, 2);
    
    if (ret == NULL) {
        printf("没找到\n");
    }
    else
    {
        printf("找到了，是 %d\n",ret->data);
    }
    //pos后插入
    LTInsert(ret, 33);
    //指定位置删除，例如删除“5 节点”
    LTNode* ret2 = LTFind(plist, 5);
    LTErase(ret2);
    LTPrint(plist);
    //销毁链表
    //LTDestroy(&plist);
    //销毁链表函数接口优化
    LTDestroy2(plist);
    plist = NULL;
}
int main(int argc, const char * argv[]) {
    Test01();
    return 0;
}
